/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.john.utils;

import com.john.Edge;
import com.john.Task;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author John
 */
public class LoadFile {

    /*
     * DEfinition of the file structure
     * Task,duration,preced,preced...
     * 
     * 
     */
    File file;
    FileReader fis;
    BufferedReader br;
    public static String FILE_SPLIT = ",";
    List<String> regs;
    List<Task> lstTask;

    public List<String> loadPertFromFile(String fileName) throws FileNotFoundException, IOException {
        lstTask = new ArrayList<>();
        regs = new ArrayList<>();
        file = new File(fileName);
        fis = new FileReader(file);
        String line = "";
        br = new BufferedReader(new FileReader(file));
         System.out.println("Raw File ");
        while ((line = br.readLine()) != null) {
            String taskes[] = line.split(FILE_SPLIT);
            for (String string : taskes) {
                System.out.print(" -> " + string);
            }
            regs.add(line);
            System.out.println("");
        }
        return regs;
    }

    public ArrayList<String> getStrPred(String REGS[]) {


        return null;
    }

    public static void main(String args[]) {
        try {
            LoadFile lo = new LoadFile();

            lo.loadPertFromFile("D:\\John\\pertExample.txt");
        } catch (FileNotFoundException ex) {
            Logger.getLogger(LoadFile.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(LoadFile.class.getName()).log(Level.SEVERE, null, ex);
        }



    }
}
